
package com.scs.application.modules.upms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.modules.upms.entity.ReportChartField;
import com.scs.application.modules.upms.mapper.ReportChartFieldMapper;
import com.scs.application.modules.upms.request.ReportChartFieldQueryRequest;
import com.scs.application.modules.upms.service.ReportChartFieldService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* 图表字段 service 实现
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class ReportChartFieldServiceImpl extends BaseServiceImpl<ReportChartFieldMapper, ReportChartField> implements ReportChartFieldService {

    @Override
    public List<ReportChartField> list(ReportChartFieldQueryRequest request) {
        List<ReportChartField> list = this.list(Wrappers.<ReportChartField>query()
                .eq(request.getReportId() != null, "report_id", request.getReportId())
            .orderByAsc("sort")
        );
        return list;
    }

    @Override
    public IPage<ReportChartField> page(ReportChartFieldQueryRequest request) {
        IPage page = this.page(request.getPage(), Wrappers.<ReportChartField>query()
                .eq(request.getReportId() != null, "report_id", request.getReportId())
                .orderByAsc("sort")
        );
        return page;
    }
}
